package com.hsc.www.pool.channel;


import com.hsc.www.common.MyPropertySourceFactory;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;


@Configuration
//@PropertySource 默认是不支持加yml，这里要加上, factory = MyPropertySourceFactory.class
@PropertySource(value = "classpath:config/pool/channel/application.yml",ignoreResourceNotFound = true, factory = MyPropertySourceFactory.class)
@SpringBootApplication
public class ChannelApp {
    public static void main(String[] args) {
        SpringApplication.run(ChannelApp.class, args);
    }


//    @Bean
//    public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
//        RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
//        rabbitAdmin.setAutoStartup(true);// 只有设置为 true，spring 才会加载 RabbitAdmin 这个类
//        return rabbitAdmin;
//    }

    @Bean
    public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
        return new RabbitTemplate(connectionFactory);
    }

    @Bean
    public Queue channelPoolQueue() {
        return new Queue("channelPoolQueue", true, false, false, null);
    }
}